using IM.Easy.Entity.Scheduled;
using IM.Easy.Infrastructure.Query;
using System.ComponentModel.DataAnnotations;


namespace IM.Easy.ScheduledServices.Dtos
{
    /// <summary>
    /// 调度任务表查询实体
    /// </summary>
    public class ScheduledJobQueryDto : QueryBase
    {
        /// <summary>
        /// 任务名称
        /// </summary>
        public string Name { get; set; }
    }


    /// <summary>
    /// 创建调度任务表dto
    /// </summary>
    public class ScheduledJobCreateDto
    {
        /// <summary>
        /// 任务唯一标识
        /// </summary>
        public Guid Id { get; set; }
        /// <summary>
        /// 任务名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 任务描述
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// 扩展表
        /// </summary>
        public ScheduledJobExtendCreateDto Extend { get; set; }

        /// <summary>
        /// 触发条件
        /// </summary>
        public JobTriggerCreateDto Trigger { get; set; }

    }


    /// <summary>
    /// 调度任务表dto
    /// </summary>
    public class ScheduledJobDto
    {
        /// <summary>
        /// 任务唯一标识
        /// </summary>
        public Guid Id { get; set; }
        /// <summary>
        /// 任务名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 任务描述
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// 调度次数
        /// </summary>
        public int FireCount { get; set; }

        /// <summary>
        /// 下次执行时间
        /// </summary>
        public DateTime? NextFireTime { get; set; }
        /// <summary>
        /// 上次执行时间
        /// </summary>
        public DateTime? LastFireTime { get; set; }

        /// <summary>
        /// 任务状态
        /// </summary>
        public SchedulerStatus Status { get; set; }

        /// <summary>
        /// 任务是否启用（1：启用，0：禁用）
        /// </summary>
        public bool IsActive { get; set; }

        public ScheduledJobExtendDto Extend { get; set; }

        public JobTriggerDto Trigger { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreatedAt { get; set; }
        /// <summary>
        /// 创建人ID
        /// </summary>
        public long CreatedBy { get; set; }
        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime? UpdatedAt { get; set; }
        /// <summary>
        /// 更新人ID
        /// </summary>
        public long UpdatedBy { get; set; }
        /// <summary>
        /// 是否已删除
        /// </summary>
        public bool IsDeleted { get; set; }
        /// <summary>
        /// 删除人ID
        /// </summary>
        public long DeletedBy { get; set; }
        /// <summary>
        /// 删除时间
        /// </summary>
        public DateTime? DeletedAt { get; set; }
    }



    /// <summary>
    /// 生效状态
    /// </summary>
    public enum EffectStatus
    {
        /// <summary>
        /// 未生效
        /// </summary>
        Pending,

        /// <summary>
        /// 生效中
        /// </summary>
        Effective,

        /// <summary>
        /// 已失效
        /// </summary>
        Expired
    }
}
